﻿//-----------------------------------------------------------------
// 该代码文件由CodeSmith的MiniAccess.cst模板创建，运行时需要MiniAccess程序集的支持。 
// 创建者  :  WuGui.Yang
// 创建时间:  2012年11月30日
//-----------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
using System.Configuration;

/// <summary>
/// 包含存取Account数据库的Access工具类和所有Entity实体类。
/// <br/>这些类均实现为Partial方式，使用时可以在单独的文件中扩展这些类的成员。
/// </summary>
namespace Ruandao.Account.EntityAccess
{
    using Ruandao.MiniAccess;
	using Ruandao.MiniAccess.SqlServer;

    /// <summary>
	/// 该类封装了SqlServerAccess针对具体某个数据库的IAccess的一个实例，提供了存取Account数据库的工具方法。
    /// <br/>该类使用了单例模式，没有公开构造方法，只能通过GetInstance()获取类的实例。
    /// </summary>
	public sealed partial class AccountAccess : SqlServerAccess
	{
        static AccountAccess()
        {
            Type[] entityTypes = { 
typeof(AccountContextEntity),typeof(RegisterUserEntity),typeof(RoleEntity),typeof(UserEntity),typeof(UsersInRolesEntity)            
            };
            string connectionString = GetConnectionString();
            SqlDatabase database = new SqlDatabase(connectionString);

            AccountAccess.tableMaps = new SqlServerTableMapGenerator(database).GetTableMaps(entityTypes);
        }

        private AccountAccess(string connstring)
            : base( connstring )
        { }
	}
    

	/// <summary>
	/// Table [ACT_AccountContext] MiniAccess Entity Class 
	/// </summary>
    [TableMap("ACT_AccountContext")]
	public partial class AccountContextEntity : EntityBase< AccountContextEntity >
	{
		#region Construct

		public AccountContextEntity():base(AccountAccess.GetInstance())
        {
            // 此处无需代码。
        }
		
		#endregion
		
		#region Get and Set Properties for All Columns.

		private int id = 0;
		public int Id
		{
			get { return this.id; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.id != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("id", this.id);
                    this.id = value;
                }
			}
		}

		private string name = String.Empty;
		public string Name
		{
			get { return this.name; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.name != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("name", this.name);
                    this.name = value;
                }
			}
		}

		private string title = String.Empty;
		public string Title
		{
			get { return this.title; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.title != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("title", this.title);
                    this.title = value;
                }
			}
		}

		private bool enablePasswordRetrieval;
		public bool EnablePasswordRetrieval
		{
			get { return this.enablePasswordRetrieval; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.enablePasswordRetrieval != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("enablePasswordRetrieval", this.enablePasswordRetrieval);
                    this.enablePasswordRetrieval = value;
                }
			}
		}

		private bool enablePasswordReset;
		public bool EnablePasswordReset
		{
			get { return this.enablePasswordReset; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.enablePasswordReset != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("enablePasswordReset", this.enablePasswordReset);
                    this.enablePasswordReset = value;
                }
			}
		}

		private bool requiresQuestionAndAnswer;
		public bool RequiresQuestionAndAnswer
		{
			get { return this.requiresQuestionAndAnswer; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.requiresQuestionAndAnswer != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("requiresQuestionAndAnswer", this.requiresQuestionAndAnswer);
                    this.requiresQuestionAndAnswer = value;
                }
			}
		}

		private bool requiresUniqueEmail;
		public bool RequiresUniqueEmail
		{
			get { return this.requiresUniqueEmail; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.requiresUniqueEmail != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("requiresUniqueEmail", this.requiresUniqueEmail);
                    this.requiresUniqueEmail = value;
                }
			}
		}

		private string passwordFormat = String.Empty;
		public string PasswordFormat
		{
			get { return this.passwordFormat; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.passwordFormat != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("passwordFormat", this.passwordFormat);
                    this.passwordFormat = value;
                }
			}
		}

		private int maxInvalidPasswordAttempts = 0;
		public int MaxInvalidPasswordAttempts
		{
			get { return this.maxInvalidPasswordAttempts; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.maxInvalidPasswordAttempts != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("maxInvalidPasswordAttempts", this.maxInvalidPasswordAttempts);
                    this.maxInvalidPasswordAttempts = value;
                }
			}
		}

		private int passwordAttemptWindow = 0;
		public int PasswordAttemptWindow
		{
			get { return this.passwordAttemptWindow; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.passwordAttemptWindow != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("passwordAttemptWindow", this.passwordAttemptWindow);
                    this.passwordAttemptWindow = value;
                }
			}
		}

		private int minRequiredPasswordLength = 0;
		public int MinRequiredPasswordLength
		{
			get { return this.minRequiredPasswordLength; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.minRequiredPasswordLength != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("minRequiredPasswordLength", this.minRequiredPasswordLength);
                    this.minRequiredPasswordLength = value;
                }
			}
		}

		private int minRequiredPasswordSymbols = 0;
		public int MinRequiredPasswordSymbols
		{
			get { return this.minRequiredPasswordSymbols; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.minRequiredPasswordSymbols != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("minRequiredPasswordSymbols", this.minRequiredPasswordSymbols);
                    this.minRequiredPasswordSymbols = value;
                }
			}
		}

		private string passwordStrengthRegularExpression = String.Empty;
		public string PasswordStrengthRegularExpression
		{
			get { return this.passwordStrengthRegularExpression; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.passwordStrengthRegularExpression != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("passwordStrengthRegularExpression", this.passwordStrengthRegularExpression);
                    this.passwordStrengthRegularExpression = value;
                }
			}
		}
		
		#endregion

		#region 获取主键所对应外键表的实体集合。
		// 函数名以Get打头，后面接着是外键表的名称，最后是Entities后缀。

		public IList< RegisterUserEntity > GetRegisterUserEntities()
		{
			return AccountAccess.GetInstance().SearchEntities< RegisterUserEntity >("WHERE AccountContextId="+id);
		}
		
		#endregion
		
		#region 获取外键所对应的实体。
		// 函数名以Get打头，后面部分是外键的名称，如果外键的名称以"FK_<表名>_"开始，则只取后半部分的名称。
		
		
		#endregion

		#region static Method
		
		// 根据主键查找和删除实体的函数。
		
		public static AccountContextEntity Fetch(int id)
		{
            return AccountAccess.GetInstance().FetechEntity< AccountContextEntity >(id);
		}
		public static int Delete(int id)
		{
            return AccountAccess.GetInstance().DeleteEntity< AccountContextEntity >(id);
		}
		
        // 根据唯一索引（UIX_AccountContext_Name）查找和删除实体的函数。
		public static AccountContextEntity FetchByName(string name)
		{
			string condition = "WHERE " + 
				"Name='" + name.ToString() + "'";
            return AccountAccess.GetInstance().FindEntity< AccountContextEntity >("WHERE " + 
				"Name='" + name.ToString() + "'");
		} 
		public static int DeleteByName(string name)
		{
			string condition = "WHERE " + 
				"Name='" + name.ToString() + "'";
            return AccountAccess.GetInstance().DeleteEntities< AccountContextEntity >("WHERE " + 
				"Name='" + name.ToString() + "'");
		} 
        // 根据唯一索引（UIX_AccountContext_Title）查找和删除实体的函数。
		public static AccountContextEntity FetchByTitle(string title)
		{
			string condition = "WHERE " + 
				"Title='" + title.ToString() + "'";
            return AccountAccess.GetInstance().FindEntity< AccountContextEntity >("WHERE " + 
				"Title='" + title.ToString() + "'");
		} 
		public static int DeleteByTitle(string title)
		{
			string condition = "WHERE " + 
				"Title='" + title.ToString() + "'";
            return AccountAccess.GetInstance().DeleteEntities< AccountContextEntity >("WHERE " + 
				"Title='" + title.ToString() + "'");
		} 
		
        // 获取表中的所有记录。
		public static IList< AccountContextEntity > GetAllEntities()
		{
            return AccountAccess.GetInstance().SearchEntities< AccountContextEntity >("");
		} 
		
        // 根据条件查找表中的记录。
		public static IList< AccountContextEntity > SearchEntities(string condition)
		{
            return AccountAccess.GetInstance().SearchEntities< AccountContextEntity >(condition);
		} 
		#endregion
		
	}

	/// <summary>
	/// Table [ACT_RegisterUser] MiniAccess Entity Class 
	/// </summary>
    [TableMap("ACT_RegisterUser")]
	public partial class RegisterUserEntity : EntityBase< RegisterUserEntity >
	{
		#region Construct

		public RegisterUserEntity():base(AccountAccess.GetInstance())
        {
            // 此处无需代码。
        }
		
		#endregion
		
		#region Get and Set Properties for All Columns.

		private Guid guid = Guid.Empty;
		public Guid Guid
		{
			get { return this.guid; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.guid != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("guid", this.guid);
                    this.guid = value;
                }
			}
		}

		private int accountContextId = 0;
		public int AccountContextId
		{
			get { return this.accountContextId; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.accountContextId != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("accountContextId", this.accountContextId);
                    this.accountContextId = value;
                }
			}
		}

		private string name = String.Empty;
		public string Name
		{
			get { return this.name; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.name != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("name", this.name);
                    this.name = value;
                }
			}
		}

		private string loweredName = String.Empty;
		public string LoweredName
		{
			get { return this.loweredName; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.loweredName != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("loweredName", this.loweredName);
                    this.loweredName = value;
                }
			}
		}

		private string nameAlias = String.Empty;
		public string NameAlias
		{
			get { return this.nameAlias; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.nameAlias != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("nameAlias", this.nameAlias);
                    this.nameAlias = value;
                }
			}
		}

		private string mobileAlias = String.Empty;
		public string MobileAlias
		{
			get { return this.mobileAlias; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.mobileAlias != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("mobileAlias", this.mobileAlias);
                    this.mobileAlias = value;
                }
			}
		}

		private string password = String.Empty;
		public string Password
		{
			get { return this.password; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.password != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("password", this.password);
                    this.password = value;
                }
			}
		}

		private int passwordFormat = 0;
		public int PasswordFormat
		{
			get { return this.passwordFormat; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.passwordFormat != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("passwordFormat", this.passwordFormat);
                    this.passwordFormat = value;
                }
			}
		}

		private string passwordSalt = String.Empty;
		public string PasswordSalt
		{
			get { return this.passwordSalt; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.passwordSalt != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("passwordSalt", this.passwordSalt);
                    this.passwordSalt = value;
                }
			}
		}

		private string mobilePin = String.Empty;
		public string MobilePin
		{
			get { return this.mobilePin; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.mobilePin != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("mobilePin", this.mobilePin);
                    this.mobilePin = value;
                }
			}
		}

		private string email = String.Empty;
		public string Email
		{
			get { return this.email; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.email != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("email", this.email);
                    this.email = value;
                }
			}
		}

		private string loweredEmail = String.Empty;
		public string LoweredEmail
		{
			get { return this.loweredEmail; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.loweredEmail != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("loweredEmail", this.loweredEmail);
                    this.loweredEmail = value;
                }
			}
		}

		private string passwordQuestion = String.Empty;
		public string PasswordQuestion
		{
			get { return this.passwordQuestion; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.passwordQuestion != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("passwordQuestion", this.passwordQuestion);
                    this.passwordQuestion = value;
                }
			}
		}

		private string passwordAnswer = String.Empty;
		public string PasswordAnswer
		{
			get { return this.passwordAnswer; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.passwordAnswer != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("passwordAnswer", this.passwordAnswer);
                    this.passwordAnswer = value;
                }
			}
		}

		private bool isApproved;
		public bool IsApproved
		{
			get { return this.isApproved; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.isApproved != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("isApproved", this.isApproved);
                    this.isApproved = value;
                }
			}
		}

		private bool isLockedOut;
		public bool IsLockedOut
		{
			get { return this.isLockedOut; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.isLockedOut != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("isLockedOut", this.isLockedOut);
                    this.isLockedOut = value;
                }
			}
		}

		private DateTime createDate = DateTime.MaxValue;
		public DateTime CreateDate
		{
			get { return this.createDate; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.createDate != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("createDate", this.createDate);
                    this.createDate = value;
                }
			}
		}

		private DateTime lastLoginDate = DateTime.MaxValue;
		public DateTime LastLoginDate
		{
			get { return this.lastLoginDate; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.lastLoginDate != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("lastLoginDate", this.lastLoginDate);
                    this.lastLoginDate = value;
                }
			}
		}

		private DateTime lastPasswordChangedDate = DateTime.MaxValue;
		public DateTime LastPasswordChangedDate
		{
			get { return this.lastPasswordChangedDate; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.lastPasswordChangedDate != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("lastPasswordChangedDate", this.lastPasswordChangedDate);
                    this.lastPasswordChangedDate = value;
                }
			}
		}

		private DateTime lastLockedOutDate = DateTime.MaxValue;
		public DateTime LastLockedOutDate
		{
			get { return this.lastLockedOutDate; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.lastLockedOutDate != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("lastLockedOutDate", this.lastLockedOutDate);
                    this.lastLockedOutDate = value;
                }
			}
		}

		private int failedPasswordAttemptCount = 0;
		public int FailedPasswordAttemptCount
		{
			get { return this.failedPasswordAttemptCount; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.failedPasswordAttemptCount != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("failedPasswordAttemptCount", this.failedPasswordAttemptCount);
                    this.failedPasswordAttemptCount = value;
                }
			}
		}

		private DateTime failedPasswordAttemptWindowStart = DateTime.MaxValue;
		public DateTime FailedPasswordAttemptWindowStart
		{
			get { return this.failedPasswordAttemptWindowStart; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.failedPasswordAttemptWindowStart != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("failedPasswordAttemptWindowStart", this.failedPasswordAttemptWindowStart);
                    this.failedPasswordAttemptWindowStart = value;
                }
			}
		}

		private int failedPasswordAnswerAttemptCount = 0;
		public int FailedPasswordAnswerAttemptCount
		{
			get { return this.failedPasswordAnswerAttemptCount; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.failedPasswordAnswerAttemptCount != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("failedPasswordAnswerAttemptCount", this.failedPasswordAnswerAttemptCount);
                    this.failedPasswordAnswerAttemptCount = value;
                }
			}
		}

		private DateTime failedPasswordAnswerAttemptWindowStart = DateTime.MaxValue;
		public DateTime FailedPasswordAnswerAttemptWindowStart
		{
			get { return this.failedPasswordAnswerAttemptWindowStart; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.failedPasswordAnswerAttemptWindowStart != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("failedPasswordAnswerAttemptWindowStart", this.failedPasswordAnswerAttemptWindowStart);
                    this.failedPasswordAnswerAttemptWindowStart = value;
                }
			}
		}

		private string comment = String.Empty;
		public string Comment
		{
			get { return this.comment; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.comment != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("comment", this.comment);
                    this.comment = value;
                }
			}
		}
		
		#endregion

		#region 获取主键所对应外键表的实体集合。
		// 函数名以Get打头，后面接着是外键表的名称，最后是Entities后缀。

		public IList< UsersInRolesEntity > GetUsersInRolesEntities()
		{
			return AccountAccess.GetInstance().SearchEntities< UsersInRolesEntity >("WHERE UserGuid='"+guid+"'");
		}
		
		#endregion
		
		#region 获取外键所对应的实体。
		// 函数名以Get打头，后面部分是外键的名称，如果外键的名称以"FK_<表名>_"开始，则只取后半部分的名称。
		
		public AccountContextEntity GetAccountContext()
		{
			return AccountAccess.GetInstance().FetechEntity< AccountContextEntity >(accountContextId);
		}
		public UserEntity GetUser()
		{
			return AccountAccess.GetInstance().FetechEntity< UserEntity >(guid);
		}
		
		#endregion

		#region static Method
		
		// 根据主键查找和删除实体的函数。
		
		public static RegisterUserEntity Fetch(Guid guid)
		{
            return AccountAccess.GetInstance().FetechEntity< RegisterUserEntity >(guid);
		}
		public static int Delete(Guid guid)
		{
            return AccountAccess.GetInstance().DeleteEntity< RegisterUserEntity >(guid);
		}
		
        // 根据唯一索引（UIX_RegisterUser_LoweredEmail）查找和删除实体的函数。
		public static RegisterUserEntity FetchByLoweredEmail(string loweredEmail)
		{
			string condition = "WHERE " + 
				"LoweredEmail='" + loweredEmail.ToString() + "'";
            return AccountAccess.GetInstance().FindEntity< RegisterUserEntity >("WHERE " + 
				"LoweredEmail='" + loweredEmail.ToString() + "'");
		} 
		public static int DeleteByLoweredEmail(string loweredEmail)
		{
			string condition = "WHERE " + 
				"LoweredEmail='" + loweredEmail.ToString() + "'";
            return AccountAccess.GetInstance().DeleteEntities< RegisterUserEntity >("WHERE " + 
				"LoweredEmail='" + loweredEmail.ToString() + "'");
		} 
        // 根据唯一索引（UIX_RegisterUser_LoweredName）查找和删除实体的函数。
		public static RegisterUserEntity FetchByLoweredName(string loweredName)
		{
			string condition = "WHERE " + 
				"LoweredName='" + loweredName.ToString() + "'";
            return AccountAccess.GetInstance().FindEntity< RegisterUserEntity >("WHERE " + 
				"LoweredName='" + loweredName.ToString() + "'");
		} 
		public static int DeleteByLoweredName(string loweredName)
		{
			string condition = "WHERE " + 
				"LoweredName='" + loweredName.ToString() + "'";
            return AccountAccess.GetInstance().DeleteEntities< RegisterUserEntity >("WHERE " + 
				"LoweredName='" + loweredName.ToString() + "'");
		} 
		
        // 获取表中的所有记录。
		public static IList< RegisterUserEntity > GetAllEntities()
		{
            return AccountAccess.GetInstance().SearchEntities< RegisterUserEntity >("");
		} 
		
        // 根据条件查找表中的记录。
		public static IList< RegisterUserEntity > SearchEntities(string condition)
		{
            return AccountAccess.GetInstance().SearchEntities< RegisterUserEntity >(condition);
		} 
		#endregion
		
	}

	/// <summary>
	/// Table [ACT_Role] MiniAccess Entity Class 
	/// </summary>
    [TableMap("ACT_Role")]
	public partial class RoleEntity : EntityBase< RoleEntity >
	{
		#region Construct

		public RoleEntity():base(AccountAccess.GetInstance())
        {
            // 此处无需代码。
        }
		
		#endregion
		
		#region Get and Set Properties for All Columns.

		private int id = 0;
		public int Id
		{
			get { return this.id; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.id != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("id", this.id);
                    this.id = value;
                }
			}
		}

		private string name = String.Empty;
		public string Name
		{
			get { return this.name; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.name != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("name", this.name);
                    this.name = value;
                }
			}
		}

		private string wareName = String.Empty;
		public string WareName
		{
			get { return this.wareName; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.wareName != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("wareName", this.wareName);
                    this.wareName = value;
                }
			}
		}

		private string loweredName = String.Empty;
		public string LoweredName
		{
			get { return this.loweredName; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.loweredName != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("loweredName", this.loweredName);
                    this.loweredName = value;
                }
			}
		}

		private string title = String.Empty;
		public string Title
		{
			get { return this.title; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.title != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("title", this.title);
                    this.title = value;
                }
			}
		}

		private string description = String.Empty;
		public string Description
		{
			get { return this.description; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.description != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("description", this.description);
                    this.description = value;
                }
			}
		}
		
		#endregion

		#region 获取主键所对应外键表的实体集合。
		// 函数名以Get打头，后面接着是外键表的名称，最后是Entities后缀。

		public IList< UsersInRolesEntity > GetUsersInRolesEntities()
		{
			return AccountAccess.GetInstance().SearchEntities< UsersInRolesEntity >("WHERE RoleId="+id);
		}
		
		#endregion
		
		#region 获取外键所对应的实体。
		// 函数名以Get打头，后面部分是外键的名称，如果外键的名称以"FK_<表名>_"开始，则只取后半部分的名称。
		
		
		#endregion

		#region static Method
		
		// 根据主键查找和删除实体的函数。
		
		public static RoleEntity Fetch(int id)
		{
            return AccountAccess.GetInstance().FetechEntity< RoleEntity >(id);
		}
		public static int Delete(int id)
		{
            return AccountAccess.GetInstance().DeleteEntity< RoleEntity >(id);
		}
		
        // 根据唯一索引（UIX_Role_WareName_LoweredRoleName）查找和删除实体的函数。
		public static RoleEntity FetchByWareName_LoweredRoleName(string wareName,string loweredName)
		{
			string condition = "WHERE " + 
				"WareName='" + wareName.ToString() + "'" + " AND " + 
				"LoweredName='" + loweredName.ToString() + "'";
            return AccountAccess.GetInstance().FindEntity< RoleEntity >("WHERE " + 
				"WareName='" + wareName.ToString() + "'" + " AND " + 
				"LoweredName='" + loweredName.ToString() + "'");
		} 
		public static int DeleteByWareName_LoweredRoleName(string wareName,string loweredName)
		{
			string condition = "WHERE " + 
				"WareName='" + wareName.ToString() + "'" + " AND " + 
				"LoweredName='" + loweredName.ToString() + "'";
            return AccountAccess.GetInstance().DeleteEntities< RoleEntity >("WHERE " + 
				"WareName='" + wareName.ToString() + "'" + " AND " + 
				"LoweredName='" + loweredName.ToString() + "'");
		} 
		
        // 获取表中的所有记录。
		public static IList< RoleEntity > GetAllEntities()
		{
            return AccountAccess.GetInstance().SearchEntities< RoleEntity >("");
		} 
		
        // 根据条件查找表中的记录。
		public static IList< RoleEntity > SearchEntities(string condition)
		{
            return AccountAccess.GetInstance().SearchEntities< RoleEntity >(condition);
		} 
		#endregion
		
	}

	/// <summary>
	/// Table [ACT_User] MiniAccess Entity Class 
	/// </summary>
    [TableMap("ACT_User")]
	public partial class UserEntity : EntityBase< UserEntity >
	{
		#region Construct

		public UserEntity():base(AccountAccess.GetInstance())
        {
            // 此处无需代码。
        }
		
		#endregion
		
		#region Get and Set Properties for All Columns.

		private Guid guid = Guid.Empty;
		public Guid Guid
		{
			get { return this.guid; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.guid != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("guid", this.guid);
                    this.guid = value;
                }
			}
		}

		private bool isAnonymous;
		public bool IsAnonymous
		{
			get { return this.isAnonymous; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.isAnonymous != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("isAnonymous", this.isAnonymous);
                    this.isAnonymous = value;
                }
			}
		}

		private DateTime lastActivityDate = DateTime.MaxValue;
		public DateTime LastActivityDate
		{
			get { return this.lastActivityDate; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.lastActivityDate != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("lastActivityDate", this.lastActivityDate);
                    this.lastActivityDate = value;
                }
			}
		}
		
		#endregion

		#region 获取主键所对应外键表的实体集合。
		// 函数名以Get打头，后面接着是外键表的名称，最后是Entities后缀。

		public IList< RegisterUserEntity > GetRegisterUserEntities()
		{
			return AccountAccess.GetInstance().SearchEntities< RegisterUserEntity >("WHERE Guid='"+guid+"'");
		}
		
		#endregion
		
		#region 获取外键所对应的实体。
		// 函数名以Get打头，后面部分是外键的名称，如果外键的名称以"FK_<表名>_"开始，则只取后半部分的名称。
		
		
		#endregion

		#region static Method
		
		// 根据主键查找和删除实体的函数。
		
		public static UserEntity Fetch(Guid guid)
		{
            return AccountAccess.GetInstance().FetechEntity< UserEntity >(guid);
		}
		public static int Delete(Guid guid)
		{
            return AccountAccess.GetInstance().DeleteEntity< UserEntity >(guid);
		}
		
		
        // 获取表中的所有记录。
		public static IList< UserEntity > GetAllEntities()
		{
            return AccountAccess.GetInstance().SearchEntities< UserEntity >("");
		} 
		
        // 根据条件查找表中的记录。
		public static IList< UserEntity > SearchEntities(string condition)
		{
            return AccountAccess.GetInstance().SearchEntities< UserEntity >(condition);
		} 
		#endregion
		
	}

	/// <summary>
	/// Table [ACT_UsersInRoles] MiniAccess Entity Class 
	/// </summary>
    [TableMap("ACT_UsersInRoles")]
	public partial class UsersInRolesEntity : EntityBase< UsersInRolesEntity >
	{
		#region Construct

		public UsersInRolesEntity():base(AccountAccess.GetInstance())
        {
            // 此处无需代码。
        }
		
		#endregion
		
		#region Get and Set Properties for All Columns.

		private Guid userGuid = Guid.Empty;
		public Guid UserGuid
		{
			get { return this.userGuid; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.userGuid != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("userGuid", this.userGuid);
                    this.userGuid = value;
                }
			}
		}

		private int roleId = 0;
		public int RoleId
		{
			get { return this.roleId; }
			set
			{
                if (this.IsDelete) throw new OrMapException("不能修改已经标识为删除的实体的属性。");
                if (this.roleId != value)
                {
                    if ( !this.IsNew ) ChangePropertyValue("roleId", this.roleId);
                    this.roleId = value;
                }
			}
		}
		
		#endregion

		#region 获取主键所对应外键表的实体集合。
		// 函数名以Get打头，后面接着是外键表的名称，最后是Entities后缀。

		
		#endregion
		
		#region 获取外键所对应的实体。
		// 函数名以Get打头，后面部分是外键的名称，如果外键的名称以"FK_<表名>_"开始，则只取后半部分的名称。
		
		public RegisterUserEntity GetRegisterUser()
		{
			return AccountAccess.GetInstance().FetechEntity< RegisterUserEntity >(userGuid);
		}
		public RoleEntity GetRole()
		{
			return AccountAccess.GetInstance().FetechEntity< RoleEntity >(roleId);
		}
		
		#endregion

		#region static Method
		
		// 根据主键查找和删除实体的函数。
		
		public static UsersInRolesEntity Fetch(Guid userGuid,int roleId)
		{
            return AccountAccess.GetInstance().FetechEntity< UsersInRolesEntity >(userGuid,roleId);
		}
		public static int Delete(Guid userGuid,int roleId)
		{
            return AccountAccess.GetInstance().DeleteEntity< UsersInRolesEntity >(userGuid,roleId);
		}
		
		
        // 获取表中的所有记录。
		public static IList< UsersInRolesEntity > GetAllEntities()
		{
            return AccountAccess.GetInstance().SearchEntities< UsersInRolesEntity >("");
		} 
		
        // 根据条件查找表中的记录。
		public static IList< UsersInRolesEntity > SearchEntities(string condition)
		{
            return AccountAccess.GetInstance().SearchEntities< UsersInRolesEntity >(condition);
		} 
		#endregion
		
	}
}
